import java.io.*;

/**
 * Author: Daniel Michalski
 * Date: 05.03.13
 */

public class Main {
    public static void main(String[] args) {
        String userHome = System.getProperty("user.home");

        try {
            BufferedWriter out = new BufferedWriter(new FileWriter(userHome + File.separator + "test.txt"));
            out.write("test");
            out.newLine();
            out.write("test2");
            out.close();

        } catch (IOException e) {
            e.printStackTrace();
        }

        try {
            BufferedReader in = new BufferedReader(new FileReader(userHome + File.separator + "test.txt"));
            String line = null;
            while ((line = in.readLine()) != null)
                System.out.println(line);
            in.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
